<template>
  <div>
    <zh-form  ref="formInfo" :colmun="1"  :model="formInfo"  labelAlign="right" >

      <zh-card style="width:100%">
        <zh-row>
          <zh-input style="float: left"  type="text"  :span="20"  prop="b0102" v-model="formInfo.b0102" label="点位名称"
                    :labelCol="{span:5}" :wrapperCol="{span:16}"/>
        </zh-row>
        <zh-row>
          <zh-input prop="inspector"   type="select"
                    :defaultFields='{label:"fullName",value:"userId",}' :options="inspectorData" label="请选择督察人员"
                    v-model="formInfo.inspectorId" :span="20"
                    :labelCol="{span:7}" :wrapperCol="{span:14}"></zh-input>
        </zh-row>
      </zh-card>

    </zh-form>
  </div>
</template>

<script>
import modal from 'ant-design-vue/es/modal'
import {
  getInspectorData,
  manualAddInspectPoint,
} from '@/services/system/whdngxlApi'
export default {
  components:{
  },
  props:{
    manualAdd:{
      type:Function,
      default:null
    }
  },
  data() {
    return {
      formInfo:{
         b0102:'',
         inspectorId:'',
      },
      inspectSetData: [],
      inspectorData:[],
    }
  },

  created() {
  },
  methods: {
    initData(data){
      if(data){
        this.inspectSetData = data
      }
      //获取督察人员下拉数据
      const params = {}
      params.manageAreas = data.manageAreas
      setTimeout(() => {
        this.$http.post(getInspectorData, params).then((res) => {
          if(res.result){
            this.inspectorData = res.result
          }
        }).catch((error) => {
          console.log(JSON.stringify(error))
        }).finally(() =>{
        })
      }, 50)
    },
    confirm(){

      if(this.formInfo.b0102 == '' || this.formInfo.b0102 == null){
        modal.warn({title: '提示', content: '点位名称不能为空'})
        return
      }
      if(this.formInfo.inspectorId == '' || this.formInfo.inspectorId == null){
        modal.warn({title: '提示', content: '督察人员不能为空'})
        return
      }
      this.inspectSetData.b0102 = this.formInfo.b0102
      this.inspectSetData.inspectorId = this.formInfo.inspectorId
      setTimeout(() => {
        this.$http.post(manualAddInspectPoint, this.inspectSetData).then((res) => {
            this.inspectSetData = res.result
            this.$emit("handleCancel")
            if(this.manualAdd){
              this.manualAdd(this.inspectSetData)
            }
        }).catch((error) => {
          console.log(JSON.stringify(error))
        }).finally(() =>{
        })
      }, 50)
    },
  }
}
</script>

<style scoped>

</style>
